/*
 * $Id: utl.h,v 1.1 2006-03-01 15:05:46 bacon Exp $
 */

#ifndef _XP_SYS_UTL_H_
#define _XP_SYS_UTL_H_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/time.h>

/* cmd for xp_halt */
enum
{
	XP_HALT_POWEROFF,
	XP_HALT_RESTART,
	XP_HALT_SHUTDOWN
};

/* opt for xp_halt */
enum
{
	XP_HALT_FORCE = (1 << 0),
	XP_HALT_TIMED = (1 << 1)
};

/* returning structure of xp_getsysinfo */
typedef struct xp_sysinfo_t xp_sysinfo_t;

struct xp_sysinfo_t
{
	xp_size_t ncpus;   /* number of processors */
	xp_time_t uptime;  /* milliseconds since system boot */
};

/* returning structure of xp_getmeminfo */
typedef struct xp_meminfo_t xp_meminfo_t;

struct xp_meminfo_t
{
	xp_ulong_t totalram;  /* total memory size in bytes */
	xp_ulong_t usedram;   /* used memory size in bytes */
	xp_ulong_t freeram;   /* available memory size in bytes */
	xp_ulong_t totalswap; /* total swap space size in bytes */
	xp_ulong_t usedswap;  /* used swap space size in bytes */
	xp_ulong_t freeswap;  /* available swap space size in bytes */
};

#ifdef __cplusplus
extern "C" {
#endif

int xp_halt (int cmd, int opt, ...);
int xp_canceltimedhalt (void);

int xp_getsysinfo (xp_sysinfo_t* sys);
int xp_getmeminfo (xp_meminfo_t* mem);

#ifdef __cplusplus
}
#endif

#endif
